package com.ruoyi.web.controller.fee;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.FeeKaiyao;
import com.ruoyi.system.service.IFeeKaiyaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 开药缴费Controller
 * 
 * @author ruoyi
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/fee/kaiyao")
public class FeeKaiyaoController extends BaseController
{
    @Autowired
    private IFeeKaiyaoService feeKaiyaoService;

    /**
     * 查询开药缴费列表
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:list')")
    @GetMapping("/list")
    public TableDataInfo list(FeeKaiyao feeKaiyao)
    {
        startPage();
        List<FeeKaiyao> list = feeKaiyaoService.selectFeeKaiyaoList(feeKaiyao);
        return getDataTable(list);
    }

    /**
     * 导出开药缴费列表
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:export')")
    @Log(title = "开药缴费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FeeKaiyao feeKaiyao)
    {
        List<FeeKaiyao> list = feeKaiyaoService.selectFeeKaiyaoList(feeKaiyao);
        ExcelUtil<FeeKaiyao> util = new ExcelUtil<FeeKaiyao>(FeeKaiyao.class);
        util.exportExcel(response, list, "开药缴费数据");
    }

    /**
     * 获取开药缴费详细信息
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(feeKaiyaoService.selectFeeKaiyaoById(id));
    }

    /**
     * 新增开药缴费
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:add')")
    @Log(title = "开药缴费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FeeKaiyao feeKaiyao)
    {
        return toAjax(feeKaiyaoService.insertFeeKaiyao(feeKaiyao));
    }

    /**
     * 修改开药缴费
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:edit')")
    @Log(title = "开药缴费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FeeKaiyao feeKaiyao)
    {
        return toAjax(feeKaiyaoService.updateFeeKaiyao(feeKaiyao));
    }

    /**
     * 删除开药缴费
     */
    @PreAuthorize("@ss.hasPermi('fee:kaiyao:remove')")
    @Log(title = "开药缴费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(feeKaiyaoService.deleteFeeKaiyaoByIds(ids));
    }
}
